<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title>
<#include "/jeecms_sys/head.html"/>
<script type="text/javascript">
$(function() {
	$(document).tooltip();
});
function getTableForm() {
	return document.getElementById('tableForm');
}
function optDelete() {
	if(Pn.checkedCount('ids')<=0) {
		$.alert("<@s.m 'global.prompt'/>","<@s.m 'error.checkRecord'/>");
		return;
	}
	$.confirm(doDelete,"<@s.m 'global.confirm'/>","<@s.m 'global.confirm.delete'/>");
}
var clicka;
function optInstall(a) {
	clicka=a;
	$.confirm(doInstall,"<@s.m 'global.confirm'/>","<@s.m 'plug.confirm.install'/>");
}
function optUninstall(a) {
	clicka=a;
	$.confirm(doUninstall,"<@s.m 'global.confirm'/>","<@s.m 'plug.confirm.uninstall'/>");
}
function doInstall(){
	 $.post("o_install.do", {
		   id:$(clicka).attr("id")
		}, function(data) {
			if(!data.login){
				$.alert("<@s.m 'global.prompt'/>","<@s.m 'login.timeout'/>");
			}else{
				if(!data.exist){
					$.alert("<@s.m 'global.prompt'/>","<@s.m 'error.plug.filenotexist'/>");
				}else{
					if(data.conflict){
						$.alert("<@s.m 'global.prompt'/>","<@s.m 'error.plug.file.conflict'/>");
					}else{
						$.alert("<@s.m 'global.prompt'/>","<@s.m 'plug.install.success'/>");
					}
				}
			}
	}, "json");
}

function doUninstall(){
	$.post("o_uninstall.do", {
			id:$(clicka).attr("id")
		}, function(data) {
			if(!data.login){
				$.alert("<@s.m 'global.prompt'/>","<@s.m 'login.timeout'/>");
			}else{
				if(!data.exist){
					$.alert("<@s.m 'global.prompt'/>","<@s.m 'error.plug.filenotexist'/>");
				}else{
					if(data.conflict){
						$.alert("<@s.m 'global.prompt'/>","<@s.m 'error.plug.file.conflict'/>");
					}else{
						$.alert("<@s.m 'global.prompt'/>","<@s.m 'plug.uninstall.success'/>");
					}
				}
			}
	}, "json");
}
function doDelete(){
	var f = getTableForm();
	f.action="o_delete.do";
	f.submit();
}
</script>
</head>
<body>
<div class="box-positon">
	<div class="rpos"><@s.m "global.position"/>: <@s.m "plug.function"/> - <@s.m "global.list"/></div>
	<form class="ropt">
		<input class="add" type="submit" value="<@s.m "global.add"/>" onclick="this.form.action='v_add.do';"/>
	</form>
	<div class="clear"></div>
</div>
<div class="body-box">
<form id="tableForm" method="post">
<input type="hidden" name="pageNo" value="${pageNo!}"/>
<@p.table value=pagination;plug,i,has_next><#rt/>
	<@p.column title="<input type='checkbox' onclick='Pn.checkbox(\"ids\",this.checked)'/>" width="25" align="center">
		<input type='checkbox' name='ids' value='${plug.id}' onclick="Pn.selectCheckBox('${plug.id}',this.checked)"/><#t/>
	</@p.column><#t/>
	<@p.column title="ID" align="center">${plug.id}</@p.column><#t/>
	<@p.column code="plug.name" align="center"><span title="${plug.description!}"><#if plug.fileConflict><span style="color: red;"><@s.m "plug.invalid"/></span></#if>${plug.name}</span></@p.column><#t/>
	<@p.column code="plug.author" align="center">${plug.author!}</@p.column><#t/>
	<@p.column code="plug.status" align="center"><#if plug.used><@s.m "plug.used"/><#else><@s.m "plug.unuse"/></#if></@p.column><#t/>
	<@p.column code="plug.uploadTime" align="center">${plug.uploadTime?string("yyyy-MM-dd HH:mm:ss")}</@p.column><#t/>
	<@p.column code="plug.installTime" align="center"><#if plug.installTime??>${plug.installTime?string("yyyy-MM-dd HH:mm:ss")}</#if></@p.column><#t/>
	<@p.column code="plug.uninstallTime" align="center"><#if plug.uninstallTime??>${plug.uninstallTime?string("yyyy-MM-dd HH:mm:ss")}</#if></@p.column><#t/>
	<@p.column code="global.operate" align="center">
		<#if plug.canInstall>
		<a href="#" class="pn-opt" id="${plug.id}" onclick="optInstall(this)"><@s.m "plug.install"/></a> | <#rt/>
		</#if>
		<#if plug.canUnInstall>
		<a href="#" class="pn-opt" id="${plug.id}" onclick="optUninstall(this)"><@s.m "plug.uninstall"/></a> | <#rt/>
		</#if>
		<a href="v_edit.do?id=${plug.id}&pageNo=${pageNo!}" class="pn-opt"><@s.m "global.edit"/></a> 
		<#if !plug.used>
		| <#rt/>
		<a href="o_delete.do?ids=${plug.id}&pageNo=${pageNo!}" onclick="if(!$.confirmToUrl(this.href)) {return false;}" class="pn-opt"><@s.m "global.delete"/></a><#t/>
		</#if>
	</@p.column><#t/>
</@p.table>
<div style="background:url(${base}/res/common/img/theme/boxTitleBG.jpg) repeat-x; height:20px; overflow:hidden;">
<input class="del-button" type="button" value="<@s.m "global.delete"/>" onclick="optDelete();"/ style="float:left; border-right:1px solid #ffffff;"></div>
</form>
</div>
<#include "/common/alert_message.html"/>
</body>
</html>